<?php





namespace App\Http\Service\Impl;


use App\Http\Service\ILogin;

use Illuminate\Support\Facades\DB;

use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;



class LoginImpl implements ILogin
{
    function login($request)
    {
        // TODO: Implement login() method.
        $username = $request->username;
        $password = md5($request->pwd);
        $userinfo = DB::select("select * from zhyl_sys_manager where mg_code=? and mg_pwd=? and mg_status=?", ["$username", "$password", 1]);
        //return $userinfo;
        if (count($userinfo) > 0) {
            Log::info("登录系统成功-id为:" . $userinfo[0]->mg_id . "--登录时间为:" . date("Y-m-d H:i:s", time()));
            Session::put("mgid", $userinfo[0]->mg_id); //保存用户的id
            Session::put("mgname", $userinfo[0]->mg_name); //保存用户的id
            return view("Index.index");
        } else {
            return "用户名或密码错误";
        }
    }
}
